<template>
  <el-form ref="plan" :model="plan" label-width="80px">
    <el-form-item label="名称">
      <el-input v-model="plan.summary"/>
    </el-form-item>
    <el-form-item label="详情">
      
      <el-input type="textarea" v-model="plan.detail"/>
    </el-form-item>
    <el-form-item label="日期">
      <el-col :span="11">
        <el-date-picker
          v-model="plan.dateStart"
          type="date"
          placeholder="选择日期"
          style="width: 100%;">
        </el-date-picker>
      </el-col>
    </el-form-item>
    <el-form-item label="时间">
      <el-col :span="11">
        <el-time-select
          v-model="plan.timeStart"
          :picker-options="{
            start: '06:00',
            end: '24:00',
            step: '00:10',
          }"
          placeholder="开始时间" 
          style="width: 100%;"
        ></el-time-select>
      </el-col>
      <el-col :span="2" class="line">-</el-col>
      <el-col :span="11">
        <el-time-select
          v-model="plan.timeEnd"
          :picker-options="{
            start: '06:00',
            end: '24:00',
            step: '00:10',
          }"
          placeholder="结束时间"
          style="width: 100%;"
        ></el-time-select>
      </el-col>
    </el-form-item>
    <el-form-item>
        <el-button type="primary" @click="modify">修改</el-button>
        <el-button type="primary" @click="close">关闭</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
export default {
    props:['plan'],
    methods:{
        close:function(){
            this.$emit('detailDialogClose');
        },
        modify:function(){
          var _this = this;
          _this.axios.post("/plan/update",this.plan).then(function(response){
            if ("OK" == response.data.code) {
              _this.$notify({
                title: '提示',
                type: 'success',
                message: '你已成功修改一条计划。'
              });
              _this.plan = {
                summary: "",
                detail: "",
                dateStart: "",
                timeStart: "",
                timeEnd: "",
                planType: "Day"
              };
              _this.$emit("detailDialogClose",response.data.data);
            }else{
              _this.$notify({
                title: '提示',
                type: 'error',
                message: '修改失败，请重试。',
                duration: 0
              });
            }
          })
        }
    }
}
</script>

<style>

</style>